package db

import (
	"context"
	"fmt"
	"github.com/redis/go-redis/v9"
	"ubt-aio-service/app/pkg/conf"
)

var RdsCli = &redis.Client{}

func InitRedis() {
	cfg := conf.Cfg.RdsConf
	RdsCli = redis.NewClient(&redis.Options{
		Addr:     cfg.Url,
		Password: cfg.Pwd,
		DB:       cfg.Num,
	})
	ctx := context.Background()
	if _, err := RdsCli.Ping(ctx).Result(); err != nil {
		panic("缓冲Redis初始化失败。" + err.Error())
		return
	}
	fmt.Println("缓冲Redis初始化成功！")
}
